<template>
	<view class="page-main">
		<next-indexed-xlist :placeHolder="$t('assist.search')" :nodata="$t('assist.nodata')"  :dataList="dataList" :showAvatar="true" @itemclick="itemclick">
			<!--这是默认插槽,额外添加部分-->
			<!--    <view class="content-block">
                <view class="title"><text>历史记录:</text></view>
                <view class="btn"><text>朝阳区</text></view>
                <view class="btn"><text>东城区</text></view>
                <view class="btn"><text>海淀区</text></view>
            </view> --> 
		</next-indexed-xlist>
	</view>
</template>

<script>
	import {setSiteId} from '@/common/tools.js'
	export default {
		data() {
			return {
				dataList: []
			}
		},
		onShow() {
			this.dataList = []
			this.getCityList();
		},
		methods: {
			itemclick(e){
				console.log(e.id.toString())
				setSiteId(e.id.toString());
				const eventChannel = this.getOpenerEventChannel();
				eventChannel.emit('acceptDataFromOpenedPage',e);
				uni.navigateBack({
					delta: 1
				});
			},

			getCityList() {
				this.$request(this.$api.cityList, {state:1}).then(res => {
					console.log(res);
					
					res.result.data.forEach((item, index) => {
						let list = {
							"id" : item.id,
							"name": item.province+" "+item.county,
							"phone": item.name,
						}
						this.dataList.push(list);
					});

				});
			}
		}
	}
</script>

<style>

</style>


<!-- {
"id": 6,
"code": "110101000000",
"name": "Asia",
"parentCode": "110100000000",
"level": 1,
"abbr": "DC",
"deleted": 1,
}, {
"id": 7,
"code": "110101000000",
"name": "东城区",
"parentCode": "110100000000",
"level": 3,
"abbr": "DC",
"deleted": 0,
}, {
id: '3',
name: '黎**',
phone: 'Asia',
img: 'https://img2.baidu.com/it/u=453253244,3693084626&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500'
}, {
id: '4',
name: '王**',
phone: '181****5576',
img: 'https://img2.baidu.com/it/u=453253244,3693084626&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500'
} -->